package ctype

import "encoding/json"

type Role int

const (
	PermissionAdmin    Role = 1 // 管理员
	PermissionUser     Role = 2 // 用户
	PermissionGuest    Role = 3 // 游客
	PermissionDisabled Role = 4 // 禁用
)

func (r Role) MarshaJSON() ([]byte, error) {
	return json.Marshal(r.String())
}

func (r Role) String() string {
	var str string
	switch r {
	case PermissionAdmin:
		str = "管理员"
	case PermissionUser:
		str = "用户"
	case PermissionGuest:
		str = "游客"
	case PermissionDisabled:
		str = "禁用"
	default:
		str = "未知"
	}
	return str
}
